﻿using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Reflection;
using SSPharma.Model;
using System.Collections.ObjectModel;
//
using System.Configuration;
using System.Data;
using System.Windows;
using DBAccess;
using SSPharma.Common;
using SSPharma.View;
using SSPharma.ViewModel;
using System.Windows.Controls;
//


namespace SSPharma.ViewModel.NhanSu
{
    public class MenuNhanSuViewModel : ViewModelBase
    {
        #region Fields

        readonly SSPharma.Model.MenuNhanSu _MenuNhanSu;
        private bool _isSelected;
        private MainNhanSuViewModel _MainNhanSuViewModel;

        #endregion

        #region Constructor

        public MenuNhanSuViewModel(SSPharma.Model.MenuNhanSu MenuNhanSu, MainNhanSuViewModel MainNhanSuViewModel)
        {
            ChildMenuCollection = new ObservableCollection<MenuNhanSuViewModel>();
            _MenuNhanSu = MenuNhanSu;
            _MainNhanSuViewModel = MainNhanSuViewModel;
        }

        #endregion

        #region MenuNhanSu Properties

        public string DepartId
        {
            get { return _MenuNhanSu.DepartId; }
            set
            {
                if (value == _MenuNhanSu.DepartId)
                    return;

                _MenuNhanSu.DepartId = value;

                base.OnPropertyChanged("DepartId");
            }
        }

        public string ORGID
        {
            get { return _MenuNhanSu.ORGID; }
            set
            {
                if (value == _MenuNhanSu.ORGID)
                    return;

                _MenuNhanSu.ORGID = value;

                base.OnPropertyChanged("ORGID");
            }
        }

        public string ParentId
        {
            get { return _MenuNhanSu.ParentId; }
            set
            {
                if (value == _MenuNhanSu.ParentId)
                    return;

                _MenuNhanSu.ParentId = value;

                base.OnPropertyChanged("ParentId");
            }
        }

        public string DepartName
        {
            get { return _MenuNhanSu.DepartName; }
            set
            {
                if (value == _MenuNhanSu.DepartName)
                    return;

                _MenuNhanSu.DepartName = value;

                base.OnPropertyChanged("DepartName");
            }
        }

        public string IconPath
        {
            get { return _MenuNhanSu.IconPath; }
            set
            {
                if (value == _MenuNhanSu.IconPath)
                    return;

                _MenuNhanSu.IconPath = value;

                base.OnPropertyChanged("IconPath");
            }
        }

        public ObservableCollection<MenuNhanSuViewModel> ChildMenuCollection
        {
            get;
            set;
        }

        #endregion

        #region Public Methods

        public MenuNhanSuViewModel GetMenuNhanSuModelByID(string _departId)
        {
            if (DepartId.Equals(_departId))
            {
                return this;
            }
            else
            {
                foreach (var item in ChildMenuCollection)
                {
                    MenuNhanSuViewModel MenuNhanSuModel = item.GetMenuNhanSuModelByID(_departId);
                    if (MenuNhanSuModel != null)
                    {
                        return MenuNhanSuModel;
                    }
                }
            }

            return null;

        }


        #endregion

        #region Private Methods

        #endregion

        #region Properties

        //public long ID_SQ
        //{
        //    get { return mh_YeuCauMuaHangHeader.ID_SQ; }
        //    set
        //    {
        //        if (value == mh_YeuCauMuaHangHeader.ID_SQ)
        //            return;
        //        mh_YeuCauMuaHangHeader.ID_SQ = value;
        //        base.OnPropertyChanged("ID_SQ");
        //    }
        //}

        #endregion
    }
}